package de.metalcon.gwt.client.pages;

import com.google.gwt.user.client.ui.FlowPanel;

import de.metalcon.gwt.client.Metalcon;

public abstract class APage extends FlowPanel {
	private final String[] parameters;

	public APage() {
		this.setStyleName(Metalcon.getBundle().css().page());

		this.parameters = null;
	}

	public APage(String[] parameter) {
		this.setStyleName(Metalcon.getBundle().css().page());

		this.parameters = parameter;
	}

	/**
	 * @see HistoryTokenAnalyzer::getPageParams()
	 * @param num
	 *            Number of the parameter to be returned
	 * @return The <code>num</code>'th parameter of the current page
	 */
	protected String getParam(int num) {
		return parameters[num];
	}

	public abstract String getHistoryToken();

	/*
	 * Reflections are to complex to be implemented on client site. Therefore
	 * use this generator method!
	 */
	public static APage generateStaticPageByName(String pageName) {
		if (pageName.equals("Test"))
			return new Test();
		if (pageName.equals("Team"))
			return new Team();

		return null;
	}
}